$def with (name,info,r)

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--[if IE]>
	<script language="javascript" type="text/javascript" src="./static/flot/excanvas.min.js"></script>
	<h1>本网站不支持你正在使用的浏览器，所以您可能遇到卡顿、错位等多种问题。推荐使用Chrome或者Firefox浏览器以获得最佳体验。</h1>
<![endif]-->
<script language="javascript" type="text/javascript" src="/static/flot/jquery.js"></script>
<script language="javascript" type="text/javascript" src="/static/flot/jquery.flot.js"></script>

<link rel="stylesheet" type="text/css" href="/static/style.css" />
<title>虚拟交易市场-历史价格</title>

<div class='content'>
<div class='top'>
<div class='navi'><a href='/orderbook'>交易系统</a></div>
<div class='navi'><a href='/rank'>排行榜</a><span style='color:red'>NEW</span></div>
<div class='navi'><a href='/welcome'>公告区</a></div>
<div class='navi'><a href='/profile'>个人设置</a><span style='color:red'>NEW</span></div>  	
</div>
<div class='sidebar'> 
	$if info[4]:
		<h3 style='text-align:center'>欢迎你：<br /><span style='color:yellow'>$info[4]</span></h3>
	$else:
		<h3 style='text-align:center'>当前帐号：$name</h3>
	<fieldset>
		<legend style="color:white">我的信息:</legend>
		<div style='text-align:left'>股票数：</div><div style='text-align:right'>$:int(info[1]) </div>
		<div style='text-align:left'>现金数：</div><div style='text-align:right'>$info[0] </div>
		<div style='margin-top:15px;margin-bottom:10px'><a href='/mylog'>我的交易情况</a></div>
	
		<div style='text-align:left'>总资产：</div><div style='text-align:right'>$info[3] </div>
	</fieldset>
	
	<fieldset>
	<legend style="color:white">进行操作:</legend>
		<a href='/orderbook'>查看所有订单</a><br />
		<a href='/neworder'>前往交易大厅</a><br />
		<a href='/price'>历史成交情况</a>
	</fieldset>
	
	<fieldset>
	<legend style="color:white">我的订单:</legend>
	$if info[2]:
		<p>我当前共有 $:len(info[2]) 个待交易订单</p>
		<div style='margin-top:15px;text-align:center'><a href='/abort'>管理我的订单</a></div>
	$else:
		当前无订单
	</fieldset>
	
	<fieldset>
	<legend style="color:white">账户操作:</legend>
		<a href='/login'>更换账户</a><br />
		<a href='mailto:an@naich.org'>联系充值</a>
	</fieldset>
</div>



<div class='frame'>
<h3>历史股价列表</h3>
<script id="source">

var jqqq = jQuery.noConflict();
jqqq(function () {
    var prices = 
    [
    	$for i in r:
    		[$i[0]*1000,$i[1]],
    ]; 
    
    var volumes = 
    [
    	$for i in r:
    		[$i[0]*1000,$i[2]],
    ]
    
    var max_volume = $:max([i[2] for i in r])
    var max_price = $:max([i[1] for i in r])
    var min_price = $:min([i[1] for i in r])
    
    var cut_line = [[ $r[0][0] * 1000, max_volume * 1.05] , [$r[-1][0]*1000, max_volume * 1.05]]
    
    

    var plot = jqqq.plot(jqqq("#placeholder"), 
    [{data : volumes, label : 'Volume', bars : {show: true, lineWidth: 1}, yaxis : 2, color:'yellow'},
     {data : prices, label : 'Price', lines : {show: true, lineWidth: 2},color:'red'},
     {data : cut_line, lines : {show: true, lineWidth: 2}, yaxis: 2, color:'white'}],
      
    {
    	xaxes: [{ mode: "time" }] , 
    	yaxes: 
    	[
    		{min:(2 * min_price - max_price), max: (1.5 * max_price - 0.5 * min_price)},
    		{position:'right', max:max_volume*3},
    	
    	],
    	legend: {position : 'nw' , backgroundColor : 'null'},
      grid: {
            backgroundColor: { colors: ["black","black"] },
            color : "white",
            hoverable : true,
            clickable : true
        }
     });

     
     function showTooltip(x, y, contents) {
        jqqq('<div id="tooltip">' + contents + '</div>').css( {
            position: 'absolute',
            display: 'none',
            top: y + 5,
            left: x + 5,
            border: '1px solid #fdd',
            padding: '2px',
            'background-color': 'white',
            opacity: 1,
            color : 'black'
        }).appendTo("body").fadeIn(200);
    }
    
    var previousPoint = null;
    jqqq("#placeholder").bind("plothover", function (event, pos, item) {        
        if (item) {
            if (previousPoint != item.dataIndex) {
                previousPoint = item.dataIndex;
                jqqq("#tooltip").remove();
                var x = new Date(item.datapoint[0]),
                    y = item.datapoint[1].toFixed(2);
                t = (x.getMonth() + 1) +'月'+ x.getDate() +'日'+ x.getHours()+'时'+x.getMinutes()+'分'
                
                showTooltip(item.pageX, item.pageY,
                            t + " , 收盘价" + y);
            }
        }
        else {
            jqqq("#tooltip").remove();
            previousPoint = null;            
        }
        
    });
    
    
    
        
})
</script>

<div id="placeholder" style="width:500px;height:300px;"></div>
<p><a href='/price'>近五日一小时收盘价</a> | 
<script type="text/javascript">
	var timeNow = new Date();
	document.write("<a href='/price?m="+(timeNow.getMonth()+1)+"&d="+timeNow.getDate()+"&tick=15'>今日十五分钟收盘价</a>");
	
</script>
</p>
</div>
</div>


<!--CBOX START-->
<div id="cboxbutton" style="position: fixed; bottom: 8px; right: 16px; width: 200px; padding: 3px; text-align: center; cursor: pointer; background-color: #EDF3F7; border:#C3D7E5 1px solid;border-radius: 3px; font-family: Tahoma, sans-serif; font-size: 14px;color:black;" onclick="togglecbox()"><b>打开聊天</b></div>
<div id="cboxdiv" style="display: none; position: fixed; bottom: 48px; right: 16px; width: 200px; background: #EDF3F7; padding: 3px; line-height: 0;border:#C3D7E5 1px solid;border-radius: 3px;color:black;"></div>

<script type="text/javascript">
var cbvis = false;
var cbload = false;
var cbcookie = "cboxvis=";

function togglecbox () {
	var cbdiv = document.getElementById("cboxdiv");
	var cbbut = document.getElementById("cboxbutton");

	if (!cbvis) {
		if (!cbload) {
			cbdiv.innerHTML = '<iframe frameborder="0" width="200" height="305" src="http://www6.cbox.ws/box/?boxid=604803&amp;boxtag=atyv1q&amp;sec=main" marginheight="2" marginwidth="2" scrolling="auto" allowtransparency="yes" name="cboxmain6-604803" style="border:#EAB412 1px solid;border-bottom:0px" id="cboxmain6-604803"></iframe><iframe frameborder="0" width="200" height="75" src="http://www6.cbox.ws/box/?boxid=604803&amp;boxtag=atyv1q&amp;sec=form" marginheight="2" marginwidth="2" scrolling="no" allowtransparency="yes" name="cboxform6-604803" style="border:#EAB412 1px solid;border-top:0px" id="cboxform6-604803"></iframe>';
			cbload = true;
		}
		cbdiv.style.display = "block";
		cbbut.innerHTML = "关闭聊天";
	}
	else {
		cbdiv.style.display = "none";
		cbbut.innerHTML = "打开聊天";
	}
	cbvis = !cbvis;
	document.cookie = cbcookie+((cbvis)?1:0);
}
// Toggle Cbox open if it was previously
var cbcookiei = document.cookie.indexOf(cbcookie);
if (cbcookiei >= 0) {
	if (document.cookie.substring(cbcookiei+cbcookie.length, cbcookiei+cbcookie.length+1) === "1") {
		togglecbox();
	}
}
</script>
<!--CBOX END-->
<!--Google Analytics Start-->
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-19155569-4']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
<!--Google Analytics End-->
